
// <copyright file="DynamicStringTrimHelperExtensions.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The dynamic string trim helper extensions.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Extensions
{
    using System;
    using System.Reflection;

    using SubhadraSolutions.Sharp.Utils.Reflection;

    /// <summary>
    /// The dynamic string trim helper extensions.
    /// </summary>
    public static class DynamicStringTrimHelperExtensions
    {
        #region Public Methods and Operators

        /// <summary>
        /// The dynamic trim strings.
        /// </summary>
        /// <param name="obj">
        /// The obj.
        /// </param>
        public static void DynamicTrimStrings(this object obj)
        {
            if (obj != null)
            {
                Type t = typeof(DynamicStringTrimHelper<>).MakeGenericType(new[] { obj.GetType() });
                t.InvokeMember("TrimStrings", BindingFlags.InvokeMethod, null, null, new[] { obj });
            }
        }

        /// <summary>
        /// The dynamic trim strings.
        /// </summary>
        /// <param name="obj">
        /// The obj.
        /// </param>
        /// <typeparam name="T">
        /// </typeparam>
        public static void DynamicTrimStrings<T>(this T obj)
        {
            if (obj != null)
            {
                DynamicStringTrimHelper<T>.TrimStrings(obj);
            }
        }

        #endregion Public Methods and Operators
    }
}
